home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HyperLib 1997 Winter - Disc 1
/
HYPERLIB-1997-Winter-CD1.ISO.7z
/
HYPERLIB-1997-Winter-CD1.ISO
/
オンラインウェア
/
BUS
/
BibTeX 1.06 FAT.sit
/
BibTeX ƒ
/
Source code
/
bibutils.h
< prev
next >
Wrap
C/C++ Source or Header
|
1996-02-18
|
8KB
|
268 lines
#pragma once
#if (__STDC__ || defined(__cplusplus))
#define STDC 1
#else
#define STDC 0
#endif
#include <stdio.h>
#include <ctype.h>
typedef struct FileDesc {
FSSpec spec;
short refNum;
} FileDesc, *FileDescPtr;
//typedef struct FileDesc FileDesc, * FileDescPtr;
extern int verbose;
#define MISSING_UNISTD_H
#define ENV_SEPAR ':'
#define DIR_DELIM ':'
#define access(fn, mode) 0 /* function not available */
#define kBufferSize 2048 /* for output buffer */
#define kReadBufferSize 1024 // for read buffer
#define FSEEK FSeek
#define UNGETC UnGetC
#define Min(x, y) ((x) < (y) ? (x) : (y))
void CloseAllFiles(void);
void FatalOSErr(const char *mess, OSErr error);
void FatalOSErr(const char *mess, const char *mess1, OSErr error);
void FormatOSErr(OSErr error, char *buffer);
void GetWindowTitle(StringPtr outName);
long GetIdxCharacter(void);
void InitializeGenInd(void);
void InitializeScanId(void);
void InitializeScanSt(void);
void IntroduceBtxFile(FSSpecPtr specPtr);
void InvokeBibtex(void);
OSErr OneTimeInitialization(void);
void SetBibtexOptions(Boolean debugOn);
void GetBibtexOptions(Boolean& debugOn);
void ReportOSErr(const char *mess, OSErr error);
#define STDC_PROTOTYPES 1
#if STDC_PROTOTYPES
#define ARGS(arg_list) arg_list
#define VOIDP void*
#define VOID_ARG void
#else
#define ARGS(arg_list) ()
#undef const
#define const
#define VOIDP char*
#define VOID_ARG
#endif
#define FREE(p) free((void*)(p))
#if STDC
#include <stdlib.h>
#undef strchr
#undef strrchr
#include <string.h>
#if !defined(MISSING_UNISTD_H)
#include <unistd.h>
#endif
#else /* NOT STDC */
/* Miscellaneous standard library routines */
#if !defined(access)
int access ARGS((const char *, int));
#endif
VOIDP calloc ARGS((size_t nitems,size_t size));
char *getenv (const char *name);
VOIDP malloc ARGS((size_t size));
char *strchr ARGS((const char *s,int c));
char *strrchr ARGS((const char *s,int c));
#endif /* STDC */
#ifndef R_OK
#define R_OK 4 /* only symbol from sys/file.h */
#endif
#undef TRUE
#define TRUE 1
#undef FALSE
#define FALSE 0
#undef NUL
#define NUL '¥0'
#undef NIL
#define NIL ""
#define TAB '¥t'
#define LFD '¥r'
#define SPC ' '
#define LSQ '['
#define BSH '¥¥'
#ifndef SW_PREFIX /* can override at compile time */
#define SW_PREFIX '-'
#endif
#define EXT_DELIM '.'
#define GET_CHAR GetC
/* Use our own versions of IsLower() and IsUpper so Makeindex will be faster */
#define ISLOWER(c) IsLower(c)
#define ISUPPER(c) IsUpper(c)
/*
If C is alphabetic, Bibtex expects the result of TOLOWER or TOUPPER to
be an unaccented alphabetic character. That¥'s why it is necessary to call
ToStrip before doing the case conversion. The casts are very important!
*/
#define TOLOWER(C) ((unsigned char) ToLower(ToStrip((unsigned char)(C))))
#define TOUPPER(C) ((unsigned char) ToUpper(ToStrip((unsigned char)(C))))
#define STREQ(A, B) (strcmp(A, B) == 0)
#define STRNEQ(A, B) (strcmp(A, B) != 0)
#define MESSAGE(F, S) { ¥
if (verbose) ¥
(void)FPrintFStdErr( F, S); ¥
}
#define FATAL(F, S) { ¥
(void)FPrintFStdErr( F, S); ¥
throw NULL; ¥
}
#define FATAL2(F, D1, D2) { ¥
(void)FPrintFStdErr( F, D1, D2); ¥
throw NULL; ¥
}
// #ifdef FCLOSE
// #undef FCLOSE
// #endif
// #define FCLOSE(FREF,SPECPTR) CloseFile(FREF,SPECPTR)
// #define CLOSE(FREF,SPECPTR) CloseFile(FREF,SPECPTR)
#define OPEN_IN(FP) OpenInputFile(FP)
#define OPEN_OUT(FP) OpenOutputFile(FP)
#define REOPEN_OUT(FN,FP) freopen(FN,"w",FP)
/*====================================================================*/
#define VERSION "MacOS version 1.0 [18-Feb-1996]"
#if 0
#endif
#define PUT_VERSION { ¥
MESSAGE("This is %s, ", pgm_fn); ¥
MESSAGE("%s.¥r", VERSION); ¥
need_version = FALSE; ¥
}
#define USAGE ¥
"Usage: %s [-c] [-d] [-e errfile] [-g] [-i] [-l] [-o ind] [-p num] ¥r¥
¥t¥t[-q] [-r] [-s sty] [-t log] [idxfile0 idxfile1 ...]¥r"
#define STYLE_PATH "BIBTEXSTYLE" /* environment variable defining search */
/* path for style files */
#define BIBTEX_INP ".aux"
#define BIBTEX_BLG ".blg"
#define BIBTEX_BIB ".bib"
#define BIBTEX_STY ".bst"
#define BIBTEX_BBL ".bbl"
#define BIBTEX_DBG ".dbg"
/*
#if !defined(BIBTEX_LOG)
#define BIBTEX_LOG ".log"
#endif
*/
/***********************************************************************
BibTeX 0.99c: Since we really never have to repeatedly allocate and
free dynamic string storage, we use chkalloc() to allocate it with
less storage overhead than malloc(), by using malloc() to get large
chunks within which we suballocate small chunks using just the storage
that they need, subject to alignment requirements. At job
termination, we free the large chunks with chkfree(), so that there
are no untidy memory leaks. All storage allocation in Bibtex 0.99c
or later uses chkalloc() instead of malloc().
We further reduce storage requirements by storing only the page
numbers that are actually used, in structures of type PAGE_PARTS. In
order to support page number strings of mixed arabic and alphabetic
characters, such as 120A, 120B, ..., we store the original page number
string in the page[] array of PAGE_PARTS. Although that structure
declares the page[] array of 1 character, don't believe that size. We
actually allocate as many characters as are needed, in the ENTER()
macro in scanid.h. The structure names in PAGE_PARTS merely provide
convenient handles to access the various fields. Integer storage
alignment requirements will require allocating each PAGE_PARTS
structure on a suitable boundary, but that can be conveniently hidden
inside chkalloc().
***********************************************************************/
#define DOT "."
#define DOT_MAX 1000 /* progress dot interval in gen_ind(), scan_idx()*/
#define CMP_MAX 1000 /* progress dot interval in sort stage */
/* Macro to print a dot every MAX invocations */
#define IDX_DOT(MAX) { ¥
BibTeX_dot = TRUE; ¥
if (BibTeX_dc++ == 0) { ¥
if (verbose) ¥
(void)FPrintFStdErr( DOT); ¥
(void) FPrintF(&gBlgDesc, DOT); ¥
} ¥
if (BibTeX_dc == MAX) ¥
BibTeX_dc = 0; ¥
}
#define STATIC /* empty definition => automatic */
#define ALL_DONE { ¥
if (fn_no > 0) { ¥
if (verbose) ¥
(void)FPrintFStdErr( ¥
"Overall %d files read (%ld entries accepted, %ld rejected).¥r", ¥
(int)(fn_no+1), (long)BibTeX_gt, (long)BibTeX_et); ¥
(void) FPrintF(&gBlgDesc, ¥
"Overall %d files read (%ld entries accepted, %ld rejected).¥r", ¥
(int)(fn_no+1), (long)BibTeX_gt, (long)BibTeX_et); ¥
} ¥
}
#define DONE(A, B, C, D) { ¥
if (verbose) ¥
(void)FPrintFStdErr( "done (%ld %s, %ld %s).¥r", ¥
(long)(A), (B), (long)(C), (D)); ¥
(void) FPrintF(&gBlgDesc, "done (%ld %s, %ld %s).¥r", ¥
(long)(A), (B), (long)(C), (D)); ¥
}
extern void *chkalloc (size_t size, size_t alignment_size);
extern void chkfree (void);
extern void *ptohrealloc(short reset);
extern void unlockhandles(void);
extern void lockhandles(void);
extern void cede_time(void);
extern FileDesc gBstDesc;
extern FileDesc gAuxDesc;
extern FileDesc gBibDesc;
extern FileDesc gBlgDesc;
extern FileDesc gBblDesc;
extern FileDesc gDbgDesc;